package com.suntimes.guangjiegou.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;

import com.suntimes.guangjiegou.R;
import com.suntimes.guangjiegou.fragment.NavigationFragment;
import com.suntimes.guangjiegou.fragment.TabFragment;

public class MainActivity extends BaseActivity {
	
	private NavigationFragment mNavigationFragment;
	private TabFragment mTabFragment;

	@Override
	protected void onCreate(Bundle bundle) {
		// TODO Auto-generated method stub
		super.onCreate(bundle);
		this.setContentView(R.layout.page_main);
		
		mTabFragment = new TabFragment();
		mNavigationFragment = new NavigationFragment(mTabFragment);
		FragmentManager fragmentManager = this.getSupportFragmentManager();
		FragmentTransaction transaction = fragmentManager.beginTransaction();
		transaction.add(R.id.page_main_container, mNavigationFragment);
		transaction.commit();
		
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
			boolean flag = mNavigationFragment.onKeyDown(keyCode, event);
			if(flag) {
				return true;
			}
		}
		return super.onKeyDown(keyCode, event);
	}
	

}
